package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
)

/*
   Author: mahaiyuan
   Date: 2021/6/7 11:32 下午
   Description:
*/
func main() {
	//getWithNoParam()
	getWithParam()
}

func getWithParam() error {
	resp, err := http.Get("http://localhost:8888/student/get?id=123456&name=李四")
	if err != nil {
		return err
	}
	defer resp.Body.Close()
	bytes, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return err
	}
	fmt.Println(string(bytes))
	return nil
}

func getWithNoParam() {
	resp, err := http.Get("http://www.baidu.com")
	if err != nil {
		fmt.Println("Get error.", err)
		return
	}
	defer resp.Body.Close()
	bytes, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		fmt.Println("read data error.", err)
		return
	}
	fmt.Println(string(bytes))
}